package study.db.sql.mapper.userbase;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.session.ResultHandler;

import java.util.List;

public interface UserBaseMapper extends BaseMapper<UserBaseEO> {

    int insertByBatch(List<UserBaseEO> entityLt);

    default Page<UserBaseEO> getPageLt(int pageNo, int pageSize) {
        Page<UserBaseEO> page = new Page<>();
        page.setCurrent(pageNo);
        page.setSize(pageSize);
        return selectPage(page, Wrappers.emptyWrapper());
    }

    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000)
    @ResultType(UserBaseEO.class)
    void getCursorLt(ResultHandler<UserBaseEO> handler);

    Cursor<UserBaseEO> getCursorV2Lt();
}
